package com.hqyj.onlineExamination.modules.exam.dao;

import com.hqyj.onlineExamination.modules.exam.entity.Achievement;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface AchievementDao {

    //新增批改试卷
    @Insert("insert into exam_achievement (create_date,user_id, subject, total_score, reference_score, "+
            "score, total_time, spend_time) values (#{createDate},#{userId}, #{subject}, #{totalScore}, " +
            "#{referenceScore}, #{score}, #{totalTime}, #{spendTime})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void insertAchievement(Achievement achievement);


    //将总成绩记录进提交试卷（修改）
    @Update("UPDATE exam_achievement SET score = #{score} WHERE id = #{id}")
    void updateScoreById(Achievement achievement);
}
